package cn.wei.sdd.core.controller.wx;


import cn.wei.common.result.R;
import cn.wei.sdd.base.util.JwtUtils;
import cn.wei.sdd.core.pojo.entity.TransFlow;
import cn.wei.sdd.core.pojo.vo.SelectTimeVO;
import cn.wei.sdd.core.pojo.vo.UserTransFlowVO;
import cn.wei.sdd.core.service.TransFlowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 交易流水表 前端控制器
 * </p>
 *
 * @author Wei
 * @since 2021-09-22
 */
@Api(tags = "用户流水管理")
@RestController
@RequestMapping("/wxApi/core/transFlow")
public class TransFlowController {

    @Resource
    private TransFlowService transFlowService;

    @ApiOperation("获取我的流水明细")
    @GetMapping("getMyTransFlow")
    public R getMyTransFlow(
            @ApiParam(value = "开始日期",required = false)
                    SelectTimeVO selectTimeVO,
                    HttpServletRequest request){
        String token = request.getHeader("token");
        Long userId = JwtUtils.getUserId(token);
        String userType = JwtUtils.getUserType(token);


        List<UserTransFlowVO> transFlowList =  transFlowService.getMyTransFlow(userType,userId,selectTimeVO);

        return R.ok().data("list",transFlowList);
    }

}

